package com.wx.controller;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.wx.model.Users;
import com.wx.service.OrderFindService;
import com.wx.serviceImpl.OrderFindServiceImpl;

/**
 * Servlet implementation class OrderFindServlet
 */
@WebServlet("/servlet/OrderFindServlet")
public class OrderFindServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public OrderFindServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		HttpSession session = request.getSession();
		Users u=(Users)session.getAttribute("login");
		String username = u.getUsername();
		OrderFindService orderFindService=new OrderFindServiceImpl();
		try {
			Users user = orderFindService.Find(username);
			request.setAttribute("truename", user.getTruename());
			request.setAttribute("phone", user.getPhone());
			request.setAttribute("home", user.getHome());
			request.setAttribute("postcode", user.getPostcode());
			request.getRequestDispatcher("../order.jsp").forward(request, response);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
